<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Login extends ST_Controller {


    /**
     * 用户登录
     */
    public function index()
    {
        //设置页面缓存
        //$this->output->cache(60);
        $user = $this->session->userdata('username');
        //$user = $this->session->item('username');

        if(!empty($user)){
            redirect(site_url('admini/home'));
        }else{
            //用户登录验证
            if (!$this->input->post()){
                $this->load->view('admin/login');
            }else{
                //登陆验证
                $this->load->model('user_mdl');
                $v = $this->user_mdl->login();
                if($v === TRUE){
                    echo 1;
                    redirect(site_url('admini/home'));
                }else{
                    $this->load->view('admin/login',array('mess'=>$v));
                }
            }
        }
    }

    /**
     * 用户退出
     */
    public function logout(){
        //$array_items = array('username' => '', 'id' => '','mail'=>'','nickname'=>'');
        $this->session->unset_userdata('username');
        redirect(site_url('admini'));
    }

    /**
     * 测试
     */
    public function test(){
        //测试目录
    }

}
